//
//(C) Copyright 2011 HongKong Airline.,Ltd. 
//
/**
 * menuinfoAction
 * 项目名称:代购系统
 * @author Mengxiangliang
 * 功能描述:
 * 历史版本:2013-01-04 v1.0.0 Mengxiangliang  创建:
 * @version [V1] 
 */
package com.gamutsoft.amb.menuinfo.action;

import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import com.gamutsoft.amb.base.action.BaseAction;
import com.gamutsoft.amb.common.bean.QueryExample;
import com.gamutsoft.amb.common.exception.BusinessException;
import com.gamutsoft.amb.common.util.ConditionUtil;
import com.gamutsoft.amb.common.util.PageUtil;
import com.gamutsoft.amb.menuinfo.model.Menuinfo;
import com.gamutsoft.amb.menuinfo.service.IMenuinfoService;


@SuppressWarnings({"serial","rawtypes"})
public class MenuinfoAction extends BaseAction {
	
	private Menuinfo menuinfo;
	
	private List<Map> menuinfoList;
	
	
	private IMenuinfoService menuinfoService;
	
	private String rootCode;//根节点

	
	/**
	 * 查询menu数据
	 */
	public void createMenuStr()throws BusinessException, Exception {
		PrintWriter out;
		out = this.getResponse().getWriter();
		try{
			if(rootCode!=null && !"".equals(rootCode)){
				Menuinfo domain=new Menuinfo();
				domain.setParentcode(rootCode);
				menuinfoList = menuinfoService.searchMenuinfoByWhere(new QueryExample(),domain);
			}
		}catch(Exception e){
			log.error(e,e);
		}
	}
	/**
	 * 返回menujson字符串
	 */
	public void generateMenuStr()throws BusinessException, Exception {
		PrintWriter out;
		out = this.getResponse().getWriter();
		String result="";
		if(rootCode!=null && !"".equals(rootCode)){
			result=menuinfoService.generateMenuStr(rootCode);
		}
		out.write(result);
	}
	

	/**
	 * @return the menuinfo
	 */
	public Menuinfo getMenuinfo() {
		return menuinfo;
	}

	/**
	 * @param menuinfo the menuinfo to set
	 */
	public void setMenuinfo(Menuinfo menuinfo) {
		this.menuinfo = menuinfo;
	}

	/**
	 * @return the menuinfoList
	 */
	public List<Map> getMenuinfoList() {
		return menuinfoList;
	}

	/**
	 * @param menuinfoList the menuinfoList to set
	 */
	public void setMenuinfoList(List<Map> menuinfoList) {
		this.menuinfoList = menuinfoList;
	}

	/**
	 * @param menuinfoService the menuinfoService to set
	 */
	public void setMenuinfoService(IMenuinfoService menuinfoService) {
		this.menuinfoService = menuinfoService;
	}

	public String getRootCode() {
		return rootCode;
	}

	public void setRootCode(String rootCode) {
		this.rootCode = rootCode;
	}
	
}
